package com.wifeacountbook.util;

import java.lang.ref.WeakReference;

import android.os.AsyncTask;

public abstract class WeakAsyncTask<Params,Progress,Result,WeakTarget> extends AsyncTask<Params, Progress, Result>{
	protected WeakReference<WeakTarget> mTarget ;
	public WeakAsyncTask(WeakTarget weakTarget){
		mTarget = new WeakReference<WeakTarget>(weakTarget);
	}
	
	protected final Result doInBackground(Params... params) {
		final WeakTarget target = mTarget.get();
		
		if(target != null){
			return this.doInBackground(target, params);
		}else{
			return null;
		}
	};

	protected abstract Result doInBackground(WeakTarget target,Params... params);
}
